'use strict';

const conn = require('../../libs/Conn');

module.exports = async function (params) {
    let querySql='';
    if(params.group_id='all'){
        querySql += `SELECT 
                            group_name AS dataType,
                            group_id AS value
         FROM user_group ug INNER JOIN department_file df  ON ug.department = df.department_id AND df.delete_sign = 1 WHERE ug.delete_sign = 1`;
    }else{
        querySql += `SELECT 
                            group_name AS dataType,
                            group_id AS value
         FROM user_group ug INNER JOIN department_file df  ON ug.department = df.department_id AND df.delete_sign = 1 WHERE ug.delete_sign = 1 AND ug.department = '${params.department_id}'`;
    }
    let rec = await conn(querySql);
    return {success: true, data: rec};

};